package com.maxjay.system.menu.web.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.maxjay.common.util.json.JsonParser;
import com.maxjay.component.metadata.web.controller.BaseServlet;
import com.maxjay.system.core.cache.SystemDataHolder;
import com.maxjay.system.menu.model.MenuTreeNode;

public class MenuTreeServlet extends BaseServlet {
	
	private static final long serialVersionUID = 1L;
       
    public MenuTreeServlet() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//		MenuTreeParser menuTreeParser = Application.getBeanContext().getBean("menuTreeParser", MenuTreeParser.class);
		MenuTreeNode menuTreeNode = SystemDataHolder.getInstance().getMenuTree();
		String menuTreeJson = JsonParser.convertArrayToJson(menuTreeNode.getChildren());
		outputJsonStream(response, menuTreeJson);
	}
	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
